<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport"/>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <link href="__PUBLIC__/checkin/css/base.css" rel="stylesheet">
    <link href="__PUBLIC__/checkin/css/index.css" rel="stylesheet">
    <link rel="stylesheet" href="__PUBLIC__/checkin/css/usercenter.css" type="text/css">
    <title>签到中心</title>
    <script src="__PUBLIC__/checkin/js/rem.js"></script>
    <script src="__PUBLIC__/checkin/js/jquery-1.7.2.js"></script>
    <script src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script type="text/javascript">
        var prom_url = '';
        var conf = '';
        wx.config( conf = {
            //// 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印
            debug: false, 
            appId: '<?php echo $appid; ?>', // 必填，公众号的唯一标识
            timestamp: '<?php echo $timestamp; ?>', // 必填，生成签名的时间戳
            nonceStr: '<?php echo $nonceStr; ?>', // 必填，生成签名的随机串
            signature: '<?php echo $signature; ?>',// 必填，签名，见附录1
            jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
        });
        wx.ready(function(){
            wx.onMenuShareAppMessage({
                title: "<?php echo $sysinfo['share_title']; ?>", // 分享标题
                desc: "<?php echo $sysinfo['share_descr']; ?>", // 分享描述
                link: prom_url, // 分享链接
                imgUrl: '', // 分享图标
                type: 'link', // 分享类型,music、video或link，不填默认为link
                dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
                success: function () { 
                // 用户确认分享后执行的回调函数
                },
                cancel: function () { 
                // 用户取消分享后执行的回调函数
                }
            });
            wx.onMenuShareTimeline({
                title: "<?php echo $sysinfo['share_title']; ?>", // 分享标题
                link: prom_url, // 分享链接
                imgUrl: '', // 分享图标
                success: function () { 
                    // 用户确认分享后执行的回调函数
                },
                cancel: function () { 
                    // 用户取消分享后执行的回调函数
                }
            });
        });
   /*
        $(function(){

            var html="<small class='addBonus'>+"+"<?php echo $data['points'] ?>"+"</small>";
            var t=null;
            function showBonus(){
                $("body").append(html);
                $(".addBonus").addClass('zoomIn').show();
                t=setTimeout(function(){
                    $(".addBonus").removeClass('zoomIn');
                    $(".addBonus").addClass('zoomOut')
                    $(".addBonus").animate({'top':'50%'},1000,function(){
                        $(".addBonus").remove();
                    });
                },2000)
            }

            var points_checkin_url = "checkin.php?act=ajax_checkin";
            $("#signBtn").on('click',function(){
                var store_id = "<?php echo $store_id ?>";
                clearTimeout(t);
                $.post(points_checkin_url, {store_id:store_id}, function(result){
                    if (typeof(result) == 'object') {
                        if (result.err_code) {
                            alert(result.err_msg);
                        } else {
                            $("#signBtn").remove();
                            $("#signText").text("您今天已经获得 <?php echo $data['points'] ?> 积分");
                            showBonus();
                        }
                    } else {
                        alert('系统异常，请重试提交');
                    }
                });
            });


        });
*/
    $(document).ready(function(){
        var html="<small class='addBonus'>xxx</small>";
        var t=null;
        function showBonus(){
            $("body").append(html);
            $(".addBonus").addClass('zoomIn').show();
            t=setTimeout(function(){
                $(".addBonus").removeClass('zoomIn');
                $(".addBonus").addClass('zoomOut')
                $(".addBonus").animate({'top':'50%'},1000,function(){
                    $(".addBonus").remove();
                });
            },2000)
        }
        $('#signBtnWaiting').hide();
        //$("#signText").hide();
        
        $("#signBtn").click(function(){
            $("#signBtn").hide();
            $('#signBtnWaiting').fadeIn();
               // clearTimeout(t);
            $.ajax({
                url: "<?php echo U('checkin'); ?>",
                data: {
                    rand: "<?php echo $ajaxValidationStr; ?>",
                },
                type: 'POST',
                dataType: 'JSON',
                //dataType: 'text',
                success: function(data){
                    //alert(JSON.stringify(data));return;
                    //$("#signBtn").();
                    if(data.errcode == 0){
                        $('#signBtnWaiting').toggle();
                        $("#signBtn").remove();
                        html="<small class='addBonus'>" + data.bonus + "</small>";
                        //$("#signText").show();
                        $("#signText").text("您今天已经获得 " + data.bonus + " 元签到奖励");
                        showBonus();
                    } else {
                        //alert(data.errmsg);
                    }
                },
                error: function(xhr){
                    $('#signBtnWaiting').fadeOut();
                    $("#signBtn").show();
                    //alert('error!');
                },
            })
        });
        
        // 分享遮罩
        $(".js-btn-copy").click(function () {
            $("#js-share-guide").removeClass("hide");
        });
        
        $("#js-share-guide").click(function () {
            $("#js-share-guide").addClass("hide");
        });
    });
    </script>
    <script>
        $(document).ready(function(){
            $.get("<?php echo U('qrcode'); ?>", {}, function(data){
                $('#prom-qr-code').attr('src', data.data.qrcode_url);
                $('#prom-url').val(data.data.url_link);
                prom_url=data.data.url_link;
            }, 'JSON');
        });
    </script>
</head>
<body>
<div class="signIn">
    <div class="signInBanner">
       <img src="__PUBLIC__/checkin/images/singinbanner.png"/>
        <div class="signBtn">
            <?php if(!count($checkin_note)){ ?>
            <a id="signBtn" href="javascript:void(0)">点我签到</a>
            <?php } ?>
            <span id="signBtnWaiting">正在等待...</span>
        </div>
    </div>
    <?php $checkin_mode = explode('|', $sysinfo['checkin_mode']);?>
    <div class="signUserInfo">
        <div class="signWrap">
            <h3>尊敬的会员 “<em><?php echo $user_info['uickname']; ?></em>”</h3>
            <p>
            <?php
            if ($checkin_mode[0] == '1') {
                echo "初次签到可得 " . $checkin_mode[1] . " 元签到奖励，<br/>连续签到每日额外增加 " . $checkin_mode[2] . " 元签到奖励，<br/>最多为 " . $checkin_mode[3] . " 元签到奖励";
            } else if ($checkin_mode[0] == '2') {
                echo "每日签到可得 " . $checkin_mode[4] . " 元签到奖励";
            } else {
                echo "未开启签到奖励";
            }
            ?>
            </p>
            <div class="signTip">
                <em id="signText">
                <?php if(count($checkin_note)){ ?>您今天已经获得 <?php echo $checkin_note[0]['bonus']; ?> 签到奖励<?php } else { ?>您还未签到哦！！<?php
                } ?>
                </em>
            </div>
        </div>
    </div>
    <div class="task">
        <div class="blueTitle">任务区</div>
        <div class="row">
            <h3><i></i>任务一</h3>
            <p>分享下面链接到小伙伴  小伙伴点击就有可能给你带来额外奖励哦</p>
            <div class="copyUrl">
                <a href="javascript:;" class="fr js-btn-copy" data-clipboard-text="<?php echo $data['share_link'] ?>">分享链接</a>
                <input id="prom-url" type="text" value="<?php echo $data['share_link'] ?>" />
            </div>
        </div>
        <div class="row">
            <h3><i></i>任务二</h3>
            <p>将下面二维码分享给小伙伴，小伙伴扫码就有可能给你带来额外奖励哦</p>
        </div>
    </div>
    <div class="follow">
        <div class="followWrap">
            <h2>欢迎关注<em>“<?php echo $sysinfo['sitetitle']; ?>”</em></h2>
            <div class="clearfix followInfo">
                <div class="followQrCode fl">
                    <img id="prom-qr-code"/>
                </div>
                <div class="followMe">
                    <div class="followText">
                        <?php echo $sysinfo['task2_descr']; ?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div id="js-share-guide" class="js-fullguide fullscreen-guide hide" style="font-size: 16px; line-height: 35px; color: #fff; text-align: center;"><span class="js-close-guide guide-close">×</span><span class="guide-arrow"></span><div class="guide-inner">请点击右上角<br>通过【发送给朋友】功能<br>把信息分享给朋友～</div></div>
</body>
</html>
